<?php
if($_SESSION['adminrights'] == false) {
    ?>
<h1>unauthorized to view page</h1>
<p>
    You do not seem to have administrative rights, therefore you can not add, edit or delete posts<br>
    If you are an administrator you might want to <a href="../classes/class.logout.php">logout</a> and login using your administrative account or either go back to <a href="../index.php?page=news">news</a>.
</p>
    <?php
    exit;
}

include($includes_path.'/functions.inc.php');
switch($apage) {
    case "";
        print('<h1>Main admin page</h1>');
        print('<p>Welcome to your personal admin page</p>');
        break;
    case "edit";
        switch($epage) {
            default;
                if(!empty($epage)) {
                    include($objects_path.'/form.editPage.php');
                }
                elseif(empty($epage)){
                    include($objects_path.'/form.addPage.php');
                }
                break;

            case "2"; //news
                if(!empty($article)) {
                    include($objects_path.'/form.editPost.php');
                }
                elseif(empty($article)) {
                    include($objects_path.'/form.addPost.php');
                }
                break;

            case "7"; //profile
                if($user == $_SESSION['userId']) {
                    include($objects_path.'/form.editProfile.php');
                }
                elseif($user != $_SESSION['userId']) {
                    print('<p>Shame on you!</p>');
                }
                break;

            case "poll";
                if($_SESSION['adminrights'] == true) {
                    include($objects_path.'/form.editPoll.php');
                }
                else {
                    print('<p>Shame on you!</p>');
                }
                break;

            case "stats";
                include($abspath.'stats/index.html');
                break;

            case "drafts";
                include($objects_path.'/postTable.obj.php');
                break;
        }
        break;
}
?>